from selenium import webdriver
from selenium.webdriver.common.by import By
import time
'''
注册(前台)
登录(前后台)
前台商品查找 
前台地址：http://192.168.1.241/hdshop     
后台地址：http://192.168.1.241/hdshop/admin/（admin/hdxy2018）
'''
#初始化
driver = webdriver.Chrome()
driver.get("http://192.168.1.241/hdshop")
driver.maximize_window()
#进入注册页面
driver.find_element(By.LINK_TEXT,"注册").click()
#填写注册信息:
driver.find_element(By.ID,"username").send_keys("liuhaitao") #输入用户名
driver.find_element(By.ID,"email").send_keys("12345678@163.com") #输入email
driver.find_element(By.ID,"password1").send_keys("123456") #输入密码
driver.find_element(By.ID,"conform_password").send_keys("123456") #确认密码
driver.find_element(By.XPATH,"//input[@name='extend_field2']").send_keys() #输入qq
driver.find_element(By.XPATH,"//input[@name='extend_field3']").send_keys() #输入办公电话
driver.find_element(By.XPATH,"//input[@name='extend_field4']").send_keys() #输入家庭电话
driver.find_element(By.XPATH,"//input[@name='extend_field5']").send_keys("12345678910") #输入手机
time.sleep(2)
# driver.find_element_by_name("sel_question").\
    # find_element_by_xpath("//select[@name='sel_question']/option[text()='我最喜爱的电影？']").click()#选择问题
driver.find_element(By.XPATH,'/html/body/div[5]/div[3]/div[1]/form/table/tbody/tr[10]/td[2]/select/option[2]').click()#选择问题
driver.find_element(By.NAME,"passwd_answer").send_keys("肖申克的救赎") #输入密码问题答案
driver.find_element(By.XPATH,"//input[@name='Submit']").click() #点击注册按钮

time.sleep(15)
driver.quit()






